<template>
	<view>
		<view class="nav-warp">
			<view class="nav-title">
				<block v-for="(item,index) in navlist" :key="index">
					<text :class="{active:index==num}" @click="hadilIndex(index)">{{item.name}}</text>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				num:0,
				navlist:[
					{
						"name":"宝贝"
					},
					{
						"name":"详情"
					},
					{
						"name":"评价"
					}
				]
			}
		},
		methods:{
			hadilIndex(index){
				this.num = index
				if(index==0){
					wx.pageScrollTo({
						scrollTop:0
					})
				}else if(index==1){
					wx.pageScrollTo({
						scrollTop:230
					})
				}else{
					wx.pageScrollTo({
						scrollTop:9999
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.nav-warp{
		position: fixed;
		top: 0;left: 0;right: 0;
		width: 100%;
		height: 60upx;
		background-color: #Ffd300;
		z-index: 999;
		
		.nav-title{
			display: flex;
			justify-content: center;
			align-items: center;
			text{
				margin: 0 20upx;
				padding: 0 0 5upx 0;
			}
		}
	}
	.active{
		border-bottom: 2px solid #000;
	}
</style>
